< previous page page_506 next page >

Page 506
Test this SQL statement by creating the SQL script in Listing 13.2 and running it using the SQL-VB5 application. Start the application and select File | New . . . to create a new script called SQLVB02.SQV. Enter the following script commands into Notepad.
Type.gifListing 13.2. Creating the SQLVB02.SQV script.
//
// SQLVB02.SQV - Testing SQL Table Management Keywords
//
// create a new database for our tests
dbMake sqlvb02.mdb;
// create a simple table
CREATE TABLE NewTable (Field1 TEXT(30), Field2 INTEGER);
// show the empty table
SELECT * FROM NewTable;
// eof (end of file)
This script creates a new database, creates a new table in the database, and displays the empty table in a result set. Use SQL-VB5 to run the script by selecting File | Run . . . and locating and loading the SQLVB02.SQV script file. Your results should appear as shown in Figure 13.7. Please note that this screen is followed by several error screens which are a result of executing an SQL statement against an empty table. Simply press OK and move past each message.
0506-01.jpg
Figure 13.7.
Results of the 
CREATE TABLE statement.
You can also use the PRIMARY KEY command when you CREATE a data table. This can be done by following the name of the primary key field with a CONSTRAINT clause. Use SQL-VB5 to edit the SQLVB02.SQV script so that it sets the Field1 column as a primary key. See Listing 13.3 for an example.

 
< previous page page_506 next page >

If you like this book, buy it!